package com.zcbl.toolkit.service;

import java.util.Objects;

/**
 * @author he peng
 * @create 2018/3/28 17:52
 * @see
 */
public abstract class AbstractServiceCallResult<E extends ServiceError,D extends Object> implements ServiceCallNotification {

    private E error;
    private D data;

    public AbstractServiceCallResult(E error, D data) {
        this.error = error;
        this.data = data;
    }

    @Override
    public boolean isSuccess() {
        if (Objects.equals(this.error.getErrorCode() , ServiceError.SUCCESS.getErrorCode())) {
            return true;
        }
        return false;
    }

    @Override
    public ServiceError getError() {
        return this.error;
    }

    @Override
    public Object getData() {
        return this.data;
    }

    @Override
    public String toString() {
        return "AbstractServiceCallResult{" +
                "error=" + error +
                ", data=" + data +
                '}';
    }
}
